<?php


namespace app\api\controller\v1;


use app\api\controller\BaseController;
use app\api\model\SjActivity;
use app\api\model\SjMsg as SjMsgModel;

class SjMsg extends BaseController
{
    protected $beforeActionList = [
        'checkExclusiveScope' => ['only' => 'getDataList']
    ];

    /**
     * 获取商家列表
     */
    public function getDataList($page,$limit)
    {
        $where = [];
        $query = SjMsgModel::where($where)->with('imgs.img')->order('order_sort desc');
        $count = $query->count();
        $result = $query->page($page, $limit)->select()->toArray();
        $data['count'] = $count;
        $data['data'] = $result;
        return $data;
    }

    /**
     * 获取商家活动
     */
    public function getDataInfo($id,$week)
    {
        $info = SjMsgModel::get($id);
        $info['activity'] = SjActivity::with('imgs.img,items')
            ->where('week_data','like','%'.$week.'%')
            ->order('order_sort desc')->select()->each(function ($item){

            })->toArray();
        return $info;
    }
}